package com.lgc.garylianglib.imgDeal;//package com.example.win10.lshutil;
//
//import android.Manifest;
//import android.content.ActivityNotFoundException;
//import android.content.Intent;
//import android.content.pm.PackageManager;
//import android.graphics.Bitmap;
//import android.graphics.BitmapFactory;
//import android.os.Build;
//import android.support.annotation.NonNull;
//import android.support.v4.app.ActivityCompat;
//import android.support.v4.content.ContextCompat;
//import android.support.v7.app.AppCompatActivity;
//import android.os.Bundle;
//import android.view.View;
//import android.widget.Button;
//import android.widget.ImageView;
//import android.widget.Toast;
//
//import com.example.lshlibrary.util.multipleUtiil.MultiplePhone;
//import com.example.lshlibrary.util.multipleUtiil.MultiplePicture;
//import com.example.lshlibrary.util.utilFixSevent.PhotoFitSevent;
//import com.lgc.garylianglib.R;
//import com.yanzhenjie.album.AlbumFile;
//
//import java.util.ArrayList;
//
///**
// * description:  适配7.0
// * autour: feijin.sh.l
// * date: 2017/12/23 17:24
// * update: 2017/12/23
// * version:
// */
//public class second extends AppCompatActivity {
//    private static final int REQUEST_CODE_TAKE_PHOTO = 0x110;
//    private static final int REQ_PERMISSION_CODE_TAKE_PHOTO = 0X112;
//    private String mCurrentPhotoPath;
//    private ImageView mIvPhoto;
//    Button button , time1,time2;
//    MultiplePhone multiplePhone;
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_second);
//        mIvPhoto = (ImageView) findViewById(R.id.id_iv);
//        button = (Button) findViewById(R.id.time);
//        time1 = (Button) findViewById(R.id.time1);
//        time2 = (Button) findViewById(R.id.time2);
//        time2.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
////                Log.e("liao",.size()+"");
//                MultiplePicture.selectImage(second.this, multiplePhone);
//            }
//        });
//
//        //接口回调 获取多张照片  并返回
//        multiplePhone = new MultiplePhone() {
//            @Override
//            public void getPhoto(ArrayList<AlbumFile> mAlbumFiles) {
//
//            }
//        };
//    }
//    /**
//     * 拍照准备（需要判断是否有权限）
//     *
//     * @param view
//     */
//    public void takePhotoNoCompress(View view) {
//        boolean b = ContextCompat.checkSelfPermission(this,
//                Manifest.permission.CAMERA)
//                != PackageManager.PERMISSION_GRANTED;//判断是否有写的权限
//        if (b) {
//            ActivityCompat.requestPermissions(this,
//                    new String[]{Manifest.permission.CAMERA,Manifest.permission.READ_EXTERNAL_STORAGE},//获取照片权限
//                    REQ_PERMISSION_CODE_TAKE_PHOTO);
//        } else {
//            mCurrentPhotoPath = PhotoFitSevent.takePhotoNoCompress(this);
//        }
//    }
//
//
//
//    /**
//     * 从相册获取图片
//     *
//     * @param view
//     */
//    public void picPhoto(View view) {
//        boolean b = ContextCompat.checkSelfPermission(this,
//                Manifest.permission.WRITE_EXTERNAL_STORAGE)
//                != PackageManager.PERMISSION_GRANTED;//判断是否有写的权限
//        if (b) {
//            ActivityCompat.requestPermissions(this,
//                    new String[]{Manifest.permission.CAMERA,Manifest.permission.READ_EXTERNAL_STORAGE},//获取照片权限
//                    REQUEST_CODE_TAKE_PHOTO);
//        } else {
//            PhotoFitSevent.takePhoto(this);
//        }
//
//
//    }
//
//
//
//    /**
//     * 权限获取结果
//     * @param requestCode
//     * @param permissions
//     * @param grantResults
//     */
//    @Override
//    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
//        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
//        switch (requestCode) {
//            case REQ_PERMISSION_CODE_TAKE_PHOTO:
//                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//                    mCurrentPhotoPath = PhotoFitSevent.takePhotoNoCompress(this);//获取权限成功后再起请求拍照功能
//                } else {
//                    // Permission Denied
//                    Toast.makeText(second.this, "Permission Denied", Toast.LENGTH_SHORT).show();
//                }
//                break;
//            case REQUEST_CODE_TAKE_PHOTO:
//                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
//                    PhotoFitSevent.takePhoto(this);//获取权限成功后再起请求拍照功能
//                } else {
//                    // Permission Denied
//                    Toast.makeText(second.this, "Permission Denied", Toast.LENGTH_SHORT).show();
//                }
//                break;
//        }
//
//    }
//
//
//
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        if (resultCode == RESULT_OK && requestCode == PhotoFitSevent.REQUEST_CODE_TAKE_PHOTO) {
//            mIvPhoto.setImageBitmap(BitmapFactory.decodeFile(mCurrentPhotoPath));
//        }
//        switch (requestCode) {
//            case PhotoFitSevent.REQUEST_CODE_TAKE_PHOTO:
//                mIvPhoto.setImageBitmap(BitmapFactory.decodeFile(mCurrentPhotoPath));
//                break;
//            case PhotoFitSevent.SELECT_PIC_BY_PICK_PHOTO:
//                if (Build.VERSION.SDK_INT >= 19) {
//                    //4.4 及以上系统使用这个方法处理图片
//                    getPhotoDir(PhotoFitSevent.handleImageOnKitKat(data, this));
//                    return;
//                }
//                //4.4 及以下系统使用这个方法处理图片
//                getPhotoDir(PhotoFitSevent.handleImageBeforeKitKat(data, this));
//                break;
//        }
//    }
//
//
//    /**
//     * 获取路径
//     *
//     * @param s
//     */
//    private void getPhotoDir(String s) {
//        if (s != null) {
//            Bitmap bitmap = BitmapFactory.decodeFile(s);
//            mIvPhoto.setImageBitmap(bitmap);
//        } else {
//            Toast.makeText(this, "failed to get image", Toast.LENGTH_SHORT);
//        }
//    }
//
//
//
//}
